package com.cloud.api.game;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import reactor.core.publisher.Mono;

@RestController
public class HelloController {
//    @GetMapping("/hello")
//    public String hello() {
//        try {
//            TimeUnit.MILLISECONDS.sleep(100);   // 1
//        } catch (InterruptedException e) {
//            return "Error during thread sleep";
//        }
//        return "Welcome to reactive world ~";
//    }
    
    @GetMapping("/hello2")
    public Mono<String> hello2() {
//    	System.out.println("Welcome to reactive world2 ~");
        return Mono.just("Welcome to reactive world2 ~")
                .delayElement(Duration.ofMillis(100)); // 1
    }
}